#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
long long A=1992919, B=18181971;
FILE *f;
char s[20];
int ts=1;
int next()
{
	A=(A*13166771+B)%1000000007;
	B=(B*67771+A)%1000000007;
	return A;
}
void createtest() { sprintf(s, "%03d", ts); ts++; f=fopen(s, "w"); }
void shuffle(int *a, int n)
{
	for(; n; swap(a[n-1], a[next()%n]), n--);
}
void out(vector <string> &t)
{
	createtest();
	int i;
	fprintf(f, "%d\n", t.size());
	for(i=0; i<t.size(); fprintf(f, "%s\n", t[i].c_str()), i++);
	t.clear();
}
void gen0()
{
	vector <string> t;
	t.push_back("1 0 4 0 0 3");
	t.push_back("-2 1 5 -2 3 4");
	t.push_back("-2 2 4 1 2 4");
	out(t);
	t.push_back("0 0 2 2 5 0");
	out(t);
	t.push_back("0 0 5 0 2 2");
	t.push_back("1 1 2 0 3 1");
	out(t);
	t.push_back("0 0 6 0 3 3");
	t.push_back("2 1 3 2 4 1");
	out(t);
	t.push_back("2 1 3 2 4 1");
	t.push_back("0 0 6 0 3 3");
	out(t);
	t.push_back("0 0 1 1 1 0");
	t.push_back("0 0 -1 0 -1 1");
	out(t);
	t.push_back("0 0 1 1 1 0");
	t.push_back("0 0 -1 0 -1 1");
	t.push_back("1 0 1 -1 2 0");
	t.push_back("1 1 2 2 1 2");
	out(t);
	t.push_back("-1 -1 -1 3 3 -1");
	t.push_back("-901 900 901 -900 -900 -900");
	t.push_back("-900 899 900 -899 900 900");
	t.push_back("-1000 -999 1000 999 1000 -1000");
	t.push_back("-999 -998 999 998 -1000 1000");
	out(t);
	t.push_back("-1 -1 -1 3 3 -1");
	t.push_back("-902 900 900 -900 -900 -900");
	t.push_back("-901 899 899 -899 900 900");
	t.push_back("-1000 -999 1000 999 1000 -1000");
	t.push_back("-999 -998 999 998 -1000 1000");
	out(t);
	t.push_back("-1 -1 -1 3 3 -1");
	t.push_back("-901 900 901 -900 -900 -900");
	t.push_back("-1000 -999 1000 999 1000 -1000");
	t.push_back("-999 -998 999 998 -1000 1000");
	out(t);
	t.push_back("-1 -1 -1 3 3 -1");
	t.push_back("-900 899 901 -900 -900 -900");
	t.push_back("-1000 -999 1000 999 1000 -1000");
	t.push_back("-999 -998 999 998 -1000 1000");
	out(t);
	t.push_back("99 99 99 103 103 99");
	t.push_back("-701 900 901 -700 -700 -700");
	t.push_back("-800 -799 1000 999 1000 -800");
	t.push_back("-799 -798 999 998 -800 1000");
	out(t);
	t.push_back("99 99 99 103 103 99");
	t.push_back("-700 899 901 -700 -700 -700");
	t.push_back("-800 -799 1000 999 1000 -800");
	t.push_back("-799 -798 999 998 -800 1000");
	out(t);
	t.push_back("-3 0 3 0 0 3");
	t.push_back("-5 -1 5 -1 0 4");
	t.push_back("2 3 -3 -2 7 -2");
	t.push_back("-2 3 4 -3 -8 -3");
	t.push_back("-5 1 5 2 0 6");
	out(t);
	t.push_back("-5 -1 5 -1 0 4");
	t.push_back("-3 0 3 0 0 3");
	t.push_back("2 3 -3 -2 7 -2");
	t.push_back("-2 3 4 -3 -8 -3");
	t.push_back("-5 1 5 2 0 6");
	out(t);
	t.push_back("-3 0 3 0 0 3");
	t.push_back("2 3 -3 -2 7 -2");
	t.push_back("-2 3 4 -3 -8 -3");
	t.push_back("-5 1 5 2 0 6");
	t.push_back("-5 -1 5 -1 0 4");
	out(t);
	t.push_back("-5 -1 5 -1 0 4");
	t.push_back("2 3 -3 -2 7 -2");
	t.push_back("-2 3 4 -3 -8 -3");
	t.push_back("-5 1 5 2 0 6");
	t.push_back("-3 0 3 0 0 3");
	out(t);
	t.push_back("-20 -10 20 -10 0 10");
	t.push_back("-5 -1 5 -1 0 4");
	t.push_back("2 3 -3 -2 7 -2");
	t.push_back("-2 3 4 -3 -8 -3");
	t.push_back("-5 1 5 2 0 6");
	t.push_back("-3 0 3 0 0 3");
	out(t);
	t.push_back("-20 -10 20 -10 0 10");
	t.push_back("-25 -9 25 -9 0 -15");
	t.push_back("-24 -15 11 20 -25 20");
	t.push_back("24 -15 -11 20 30 25");
	t.push_back("-5 -1 5 -1 0 4");
	t.push_back("2 3 -3 -2 7 -2");
	t.push_back("-2 3 4 -3 -8 -3");
	t.push_back("-5 1 5 2 0 6");
	t.push_back("-3 0 3 0 0 3");
	out(t);
	t.push_back("-6 1 -7 -1 -5 -3");
	t.push_back("-4 1 -5 -3 -3 -4");
	t.push_back("-2 1 -3 -4 -1 -4");
	t.push_back("0 1 -1 -4 1 -4");
	t.push_back("6 1 7 -1 5 -3");
	t.push_back("4 1 5 -3 3 -4");
	t.push_back("2 1 3 -4 1 -4");
	t.push_back("-6 -1 -7 1 -5 3");
	t.push_back("-4 -1 -5 3 -3 4");
	t.push_back("-2 -1 -3 4 -1 4");
	t.push_back("0 -1 -1 4 1 4");
	t.push_back("6 -1 7 1 5 3");
	t.push_back("4 -1 5 3 3 4");
	t.push_back("2 -1 3 4 1 4");
	out(t);
	t.push_back("0 0 -1 3 1 3");
	t.push_back("0 0 -1 -3 1 -3");
	t.push_back("0 0 3 -1 3 1");
	t.push_back("0 0 -3 -1 -3 1");
	t.push_back("-4 4 -3 1 -1 3");
	t.push_back("-4 -4 -3 -1 -1 -3");
	t.push_back("4 -4 3 -1 1 -3");
	t.push_back("4 4 3 1 1 3");
	out(t);
}
#define N 510
struct P
{
	long long x, y;
	P(long long x=0, long long y=0): x(x), y(y) {}
};
P operator +(P a, P b) { return P(a.x+b.x, a.y+b.y); }
P operator -(P a, P b) { return P(a.x-b.x, a.y-b.y); }
P operator *(P a, long long b) { return P(a.x*b, a.y*b); }
long long operator &(P a, P b) { return a.x*b.x+a.y*b.y; }
long long operator *(P a, P b) { return a.x*b.y-a.y*b.x; }
bool operator ==(P a, P b) { return a.x==b.x && a.y==b.y; }
bool is(P a, P b, P c, P d)
{
	long long d0, d1, d2;
	d0=(b-a)*(d-c);
	if(d0) return 1;
	d1=(c-a)*(d-c);
	d2=(c-a)*(b-a);
	if(d1 || d2) return 1;
	return ((c-a)&(c-b))>=0 && ((d-a)&(d-b))>=0 && ((a-c)&(a-d))>=0 && ((b-c)&(b-d))>=0;
}
void gen1(int n, int h)
{
	createtest();
	int i, j, k, l, v, d, x, y;
	P m[N][4];
	fprintf(f, "%d\n", n*h*h);
	d=2000/h;
	for(x=0; x<h; x++)
		for(y=0; y<h; y++)
			for(i=0; i<n; )
			{
				for(j=0; j<3; m[i][j]=P(next()%d-1000+x*d, next()%d-1000+y*d), j++);
				m[i][3]=m[i][0];
				if((m[i][2]-m[i][0])*(m[i][1]-m[i][0])==0) continue;
				v=1;
				for(j=0; j<i; j++)
					for(k=0; k<3; k++)
						for(l=0; l<3; v&=is(m[i][k], m[i][k+1], m[j][l], m[j][l+1]), l++);
				if(v)
				{
					for(j=0; j<3; fprintf(f, "%lld %lld%c", m[i][j].x, m[i][j].y, j<2?' ':'\n'), j++);
					i++;
				}
			}
}
double ang(P a, P b, P c)
{
	return fabs(atan2((double)((b-a)*(c-a)), (double)((b-a)&(c-a))));
}
void gen2(int n, int h)
{
	createtest();
	int i, j, k, l, v, d, x, y, g;
	P m[N][4];
	fprintf(f, "%d\n", n*h*h);
	d=2000/h;
	g=2*d/pow((double)n, 0.25);
	for(x=0; x<h; x++)
		for(y=0; y<h; y++)
			for(i=0; i<n; )
			{
				m[i][0]=P(next()%d+x*d-1000, next()%d+y*d-1000);
				m[i][1]=m[i][0]+P(next()%g-g/2, next()%g-g/2);
				m[i][2]=m[i][0]+P(next()%g-g/2, next()%g-g/2);
				m[i][3]=m[i][0];
				if((m[i][2]-m[i][0])*(m[i][1]-m[i][0])==0) continue;
				if(m[i][1].x<x*d-1000 || m[i][1].x>(x+1)*d-1000 || m[i][1].y<y*d-1000 || m[i][1].y>(y+1)*d-1000) continue;
				if(m[i][2].x<x*d-1000 || m[i][2].x>(x+1)*d-1000 || m[i][2].y<y*d-1000 || m[i][2].y>(y+1)*d-1000) continue;
				if(ang(m[i][0], m[i][1], m[i][2])<0.3) continue;
				if(ang(m[i][1], m[i][2], m[i][0])<0.3) continue;
				if(ang(m[i][2], m[i][0], m[i][1])<0.3) continue;
				v=1;
				for(j=0; j<i; j++)
					for(k=0; k<3; k++)
						for(l=0; l<3; v&=is(m[i][k], m[i][k+1], m[j][l], m[j][l+1]), l++);
				if(v)
				{
					for(j=0; j<3; fprintf(f, "%lld %lld%c", m[i][j].x, m[i][j].y, j<2?' ':'\n'), j++);
					i++;
				}
			}
}
void gen3(int n)
{
	createtest();
	int i, a[N], b[N];
	for(i=0; i<n; a[i]=i, b[i]=i, i++);
	shuffle(a, n);
	shuffle(b, n);
	fprintf(f, "%d\n", n);
	for(i=0; i<n/2; fprintf(f, "%d %d %d %d %d %d\n", a[i], -10, a[i]+1, -10, b[i], 510), i++);
	for(; i<n; fprintf(f, "%d %d %d %d %d %d\n", -10, a[i], -10, a[i]+1, 510, b[i]), i++);
}
void gen4(int n)
{
	createtest();
	int i, a[N], b[N], c[N];
	for(i=0; i<n; a[i]=i, b[i]=i, c[i]=i, i++);
	shuffle(a, n);
	shuffle(b, n);
	shuffle(c, n);
	fprintf(f, "%d\n", n);
	for(i=0; i<n; fprintf(f, "%d %d %d %d %d %d\n", -a[i]-1, 2*a[i]-501, b[i]+1, 2*b[i]-501, c[i]-500, 501), i++);
}
void gen5(int n)
{
	createtest();
	int i, j;
	fprintf(f, "%d\n", n);
	for(j=0; j<n; i=j%2?j/2:499-j/2, fprintf(f, "%d %d %d %d %d %d\n", -i-1, 2*i-501, 500-i, 2*(499-i)-501, 2*i-500, 501), j++);
}
void gen6(int n)
{
	createtest();
	int i;
	fprintf(f, "%d\n", n);
	for(i=0; i<n; fprintf(f, "%d %d %d %d %d %d\n", 2*i, 1000, 2*i+1, 1000, 1000, 1000-2*i-1), i++);
}
int main()
{
	int i;
	gen0();
	for(i=0; i<5; i++)
		gen1(10, 1);
	gen1(500, 1);
	gen1(125, 2);
	gen1(50, 3);
	gen1(31, 4);
	gen1(20, 5);
	gen1(13, 6);
	gen1(10, 7);
	gen1(5, 10);
	gen2(500, 1);
	gen2(125, 2);
	gen2(50, 3);
	gen2(31, 4);
	gen2(20, 5);
	gen2(13, 6);
	gen2(10, 7);
	gen2(5, 10);
	gen3(500);
	gen4(500);
	gen5(500);
	gen6(500);
	return 0;
}